<?php
use think\facade\Route;
use think\facade\Config;
use think\exception\HttpResponseException;
/*不登陆*/
Route::group('v1',function () {
    /*异步*/
    Route::post('notify', 'v1.store.Draw/notify');
    /*工具类 */
    Route::group('untils',function () {
        Route::post('upload', 'v1.untils.Upload/upload');
        Route::post('send/sms', 'v1.untils.Sms/send');
        Route::post('content', 'v1.untils.content/get');
        Route::post('message/get', 'v1.untils.message/get');
        Route::post('message/list', 'v1.untils.message/list');
    });

    /*商户*/
    Route::group('store',function () {
        /* 参数*/
        Route::post('store_type', 'v1.home.Store/storeType');

        /*登陆*/
        Route::post('Login', 'v1.store.login.Login/index');
        Route::post('SmsLogin', 'v1.store.login.Login/code');
        Route::post('WxLogin/phone', 'v1.store.login.WxLogin/phone');
        Route::post('WxLogin/session', 'v1.store.login.WxLogin/session');

    });







    /*用户*/
    Route::group('user',function () {
        /*登陆*/
        Route::post('Login', 'v1.user.login.Login/index');
        Route::post('SmsLogin', 'v1.user.login.Login/code');
        Route::post('WxLogin/phone', 'v1.user.login.WxLogin/phone');
        Route::post('WxLogin/session', 'v1.user.login.WxLogin/session');

    });




})->middleware(\app\api\middleware\AllowOriginMiddleware::class);

/*登录*/
Route::group('v1',function () {

    Route::group(function () {


        /*系统类*/
        Route::group('system',function () {
            Route::post('message', 'v1.system.Upload/uploadImage');

        });
        /*商铺管理*/
        Route::group('store',function () {
            /*商铺入驻申请*/
            Route::post('in', 'v1.store.base.MoveIn/set');
            Route::post('get', 'v1.store.base.MoveIn/get');
            /*商铺用户信息修改*/
            Route::post('user/get', 'v1.store.base.info/get');
            Route::post('user/set', 'v1.store.base.info/set');

            /*商铺信息修改*/
            Route::post('getinfo', 'v1.store.base.info/get');
            Route::post('set', 'v1.home.base/set');

            /*商铺相册管理*/
            Route::post('Album/get', 'v1.store.base.Album/get');
            Route::post('Album/set', 'v1.store.base.Album/set');
            Route::post('Album/remove', 'v1.store.base.Album/remove');

            /*商铺图片管理*/
            Route::post('Photo/get', 'v1.store.base.Photo/get');
            Route::post('Photo/set', 'v1.store.base.Photo/set');
            Route::post('Photo/remove', 'v1.store.base.Photo/remove');

            /*商铺抽奖*/
            Route::post('lottery/draw', 'v1.store.lottery.Draw/get');
            Route::post('lottery/set', 'v1.store.lottery.Draw/set');
            Route::post('lottery/get_code', 'v1.store.lottery.Draw/get_code');
            Route::post('lottery/get_code_num', 'v1.store.lottery.Draw/get_code_num');

            /*支付记录*/
            Route::post('lottery/pay_list', 'v1.store.lottery.Draw/pay_list');


        });


        /*商户*/
        Route::group('home',function () {
            /* 参数*/
            Route::post('store/get', 'v1.home.Store/get');
            Route::post('Decoration', 'v1.home.Decoration/index');

        });
        /*用户管理*/
         Route::group('user',function () {

             /*用户信息修改*/
             Route::post('get', 'v1.user.base.info/get');

             Route::post('set', 'v1.user.base.info/set');


             /* 获取抽奖次数*/
             Route::post('lottery/get', 'v1.user.lottery.Number/get');
             Route::post('lottery/set', 'v1.user.lottery.Number/set');


             /*抽奖*/
             Route::post('draw/get', 'v1.user.lottery.Draw/set');



         });








    });

})->middleware([\app\api\middleware\AllowOriginMiddleware::class,\app\api\middleware\AuthTokenMiddleware::class]);

Route::miss(function () {
    if (app()->request->isOptions()) {
        $header = Config::get('cookie.header');
        unset($header['Access-Control-Allow-Credentials']);
        return \think\Response::create('ok')->code(200)->header($header);
    } else
        throw new HttpResponseException(json(['code' => 0, 'info' => lang('禁用访问！')]));
});
